package com.service.device;

import com.dao.secondary.device.DevicePcbBaseInfoMapper;
import com.github.pagehelper.PageHelper;
import com.model.domain.device.GetDevicePcbBaseInfoDO;
import com.model.pojo.device.DevicePcbBaseInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Author: zql
 * @Description: 【请填写功能名称】服务
 * @Data: 2023-03-29
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DevicePcbBaseInfoService {
    private final DevicePcbBaseInfoMapper devicePcbBaseInfoMapper;

    /**
     * 获取所有信息
     * @author tm
     * @date 2023-05-26 7:10
     * @param getDevicePcbBaseInfoDO
     * @return List<DevicePcbBaseInfo>
     */
    public List<DevicePcbBaseInfo> getAllList(GetDevicePcbBaseInfoDO getDevicePcbBaseInfoDO){
        PageHelper.clearPage();
        PageHelper.orderBy(getDevicePcbBaseInfoDO.getSortRow() + getDevicePcbBaseInfoDO.getSortOrder());
        return devicePcbBaseInfoMapper.selectList(getDevicePcbBaseInfoDO);
    }

    /**
     * 获取分页信息
     * @author tm
     * @date 2023-06-07 1:22
     * @param getDevicePcbBaseInfoDO
     * @return List<DevicePcbBaseInfo>
     */
    public List<DevicePcbBaseInfo> getPageList(GetDevicePcbBaseInfoDO getDevicePcbBaseInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getDevicePcbBaseInfoDO.getPage(),getDevicePcbBaseInfoDO.getPageSize(),getDevicePcbBaseInfoDO.getSortRow() + getDevicePcbBaseInfoDO.getSortOrder());
        return devicePcbBaseInfoMapper.selectList(getDevicePcbBaseInfoDO);
    }
    public List<DevicePcbBaseInfo> selectSimExpireList(GetDevicePcbBaseInfoDO getDevicePcbBaseInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getDevicePcbBaseInfoDO.getPage(),getDevicePcbBaseInfoDO.getPageSize(),getDevicePcbBaseInfoDO.getSortRow() + getDevicePcbBaseInfoDO.getSortOrder());
        return devicePcbBaseInfoMapper.selectSimExpireList(getDevicePcbBaseInfoDO);
    }

    /**
     * 根据ID获取设备信息
     * @author tm
     * @date 2023-06-08 20:57
     * @param id
     * @return DevicePcbBaseInfo
     */
    public DevicePcbBaseInfo getById(Long id){
        return devicePcbBaseInfoMapper.selectByPrimaryKey(id);
    }


    /**
     * 根据设备编号查询
     * @author tm
     * @date 2023-06-21 14:46
     * @param dtu
     * @return DevicePcbBaseInfo
     */
    public DevicePcbBaseInfo getByDtu(String dtu){
        return devicePcbBaseInfoMapper.selectByDtu(dtu);
    }
    public List<DevicePcbBaseInfo> getBySim(String sim){
        return devicePcbBaseInfoMapper.selectBySim(sim);
    }
    public DevicePcbBaseInfo getByShortDtu(String shortDtu){
        return devicePcbBaseInfoMapper.selectByShortDtu(shortDtu);
    }

    public int update(DevicePcbBaseInfo baseInfo){
        return devicePcbBaseInfoMapper.updateByPrimaryKeySelective(baseInfo);
    }

    public void updateList(List<DevicePcbBaseInfo> baseList){
        devicePcbBaseInfoMapper.updateListSelective(baseList);
    }

    public long countByBatchId(long batchId){
        return devicePcbBaseInfoMapper.countByBatchId(batchId);
    }
    public List<DevicePcbBaseInfo> getByImei(String imei){
        return devicePcbBaseInfoMapper.selectByImei(imei);
    }
}
